﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using DTO;

namespace DAO
{
    public class TaiKhoanDAO
    {
        public List<TaiKhoanDTO> LayTaiKhoan()
        {
            SqlConnection conn = DataProvider.ConnectDB();
            string sql = "SELECT * FROM TaiKhoan WHERE Deleted = 0";
            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataReader read = cmd.ExecuteReader();
            List<TaiKhoanDTO> tk = new List<TaiKhoanDTO>();
            while (read.Read())
            {
                TaiKhoanDTO temp = new TaiKhoanDTO();
                temp.TenDangNhap = read.GetString(1);
                temp.MatKhau = read.GetString(2);
                temp.NgayLap = read.GetDateTime(3);

                tk.Add(temp);
            }
            return tk;
        }
    }
}
